#include "e2d/imgui/trans/Editor.h"
#include "e2d/core/trans/Maps.h"

#include "e2d/ui/Utils.h"

using Editor = e2d::BasicEditor;

template<>
bool Editor::Edit<e2d::AnimationMap>(const std::string& l, e2d::AnimationMap& e)
{
	bool combo = ImGui::BeginCombo(l.c_str(), e.m_Index.m_Name.c_str());

	if (combo)
	{
		for (const auto& [key, value] : ModelImporter::m_ModelMetaData.m_ModelMetaCache)
		{
			ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 1.0f, 0.5f, 1.0f));
			ImGui::Text(key.c_str());
			ImGui::PopStyleColor();

			for (const auto& value2 : value.m_AnimationMetaIndexes)
			{
				ImGui::PushID(&value2);
				const std::string& itemLabel = value2.m_Name;
				bool selectable = ImGui::Selectable(itemLabel.c_str(), e.m_Index.m_FileId == value2.m_FileId);
				if (selectable)
				{
					e.m_Index = value2;
				}
				ImGui::PopID();
			}

		}

		ImGui::EndCombo();
	}

	return false;

}